<?php if (!defined('THINK_PATH')) exit();?>﻿<!DOCTYPE html>
<html><head>
		<meta charset="UTF-8">        
        <title>订单确认页 － ZOL商城｜中关村在线旗下网上商城</title>
        <link href="/zj125/Public/Home/order/css/orderPublic_v1.css" rel="stylesheet" type="text/css">
		<link href="/zj125/Public/Home/order/css/order_v1.css" rel="stylesheet" type="text/css">
		<script src="/zj125/Public/Home/order/js/jquery.js"></script>	
		<script src="/zj125/Public/Home/order/js/userAddress.js"></script>
		<style>
		.msg{background-color:#1C86EE;width:200px;height:30px;position:absolute;left:50%;margin-left:-100px;border-radius:8px;display:none;color:white}
		</style>
	</head>
<body>
<div class="msg" align="center"></div>
<input type="hidden" name="uid" value="<?php echo ($uid); ?>">
<div class="header clearfix">
    <!--logo样式 -->
    <div class="logo">
        <a href="" title="ZOL经销商"><img src="/zj125/Public/Home/order/img/dealer_212x40.jpg" width="212" height="40"></a>
    </div>
    <div class="flow-step">        
		<ul class="flow-step-2">
			<li class="s1">加入购物车</li>
			<li class="s2">下订单</li>
			<li class="s3">去付款</li>
			<li class="s4">确认收货</li>
			<li class="s5">评价</li>
		</ul>
	</div>
</div>
<!-- //header -->
<div class="wrapper">
<form action="" name="confirmOrder" id="confirmOrder" method="post">
	<!-- 收货人信息 -->
<div class="container consignee">
	<table>
		<tbody><tr>
			<td class="cell-1">收货人信息</td>
			<td class="cell-2">
				<ul class="address-list">
					<?php if(is_array($resu)): foreach($resu as $key=>$vv): ?><li class="current" id="<?php echo ($vv["id"]); ?>">
						<input type="hidden" name="deleid" class="" value="<?php echo ($vv["id"]); ?>">
							<label >
								<input autocomplete="off" id="addressId" name="addressId" type="radio" value="<?php echo ($vv["person"]); echo ($vv["address"]); echo ($vv["xxaddress"]); echo ($vv["moblie"]); ?>"
								<?php if($vv["type"] == 1): ?>checked<?php endif; ?>>
								<span>
									<?php if($vv["type"] == 1): ?><span style="color:red">[默认]</span>&nbsp;&nbsp;<?php endif; ?><strong><em><?php echo ($vv["person"]); ?></em></strong>
								</span>&nbsp;&nbsp;<?php echo ($vv["address"]); ?>&nbsp;&nbsp;<?php echo ($vv["xxaddress"]); ?> &nbsp;&nbsp;<?php echo ($vv["moblie"]); ?>
							</label>
							<div class="operate" id="operate_<?php echo ($vv["id"]); ?>">
								<span><a class="addredit" data-id="<?php echo ($vv["id"]); ?>" style="cursor:pointer;">编辑</a>
								<a class="addrdele" data-id="<?php echo ($vv["id"]); ?>" style="cursor:pointer;">删除</a></span>
							</div>
							<!--删除弹窗-->
							<div class="delete-tooltip-box" id="deleteBox" style="display:none;">
								<div class="delete-tooltip">
									<i class="close"></i>
									<p>请问确认删除该地址吗？</p>
									<div class="btn clearfix">
										<a class="ack-btn" style="cursor:pointer;">确认删除</a>
										<a style="cursor:pointer;" class="cancel-btn">取消</a>
									</div>
								</div>
							</div>
							
							<div class="infor-editor editBox" id="infor-editor_<?php echo ($vv["id"]); ?>" style="display:none">
							<div class="editBox_<?php echo ($vv["id"]); ?>">
								<dl>
									<dt><em class="xh">*</em>收货人：</dt>
									<dd>
										<input name="truename" id="deliverName" type="text" value="" class="text recinput" maxlength="10">
										<span class="wrong-tips none" id="deliverNameTips">请填写收货人</span>
									</dd>
								</dl>
								<dl class="area">
									<dt>
										<em class="xh">*</em>所在地区：
									</dt>
									<dd class="clearfix" >
										<select name="province" id="province_<?php echo ($vv["id"]); ?>">
											<option value=""></option>
										</select>
										<select name="city" id="city_<?php echo ($vv["id"]); ?>">
											<option value=""></option>
										</select>
										<select name="area" id="area_<?php echo ($vv["id"]); ?>">
											<option value=""></option>
										</select>	
									</dd>
								</dl>                                        
								<dl class="detailed-address">
									<dt><em class="xh">*</em>详细地址：</dt>
									<dd>
										<input name="addres" id="deliverAddress" type="text" value="" class="text addinput" maxlength="30"><span class="wrong-tips none" id="deliverAddressTips">请填写详细地址，5~30字</span>
									</dd>
								</dl>
								<div class="number clearfix">
									<dl>
										<dt><em class="xh">*</em>手机号码：</dt>
										<dd>
											<input name="moblie" id="deliverMobile" type="text" value="" class="text" maxlength="11">
											<em class="tips">或</em>
										</dd>
									</dl>
									<dl class="fixed-line">
										<dt>固定电话：</dt>
										<dd>
											<input name="tel" id="deliverPhone" type="text" value="" class="text" maxlength="17">
											<em class="tips" id="deliverMobilePhoneTips" style="line-height:25px">手机号码和固定电话请至少输入一个</em>
										</dd>
									</dl>
								</div>
								<label class="setup-default">
									<input name="deliverDefault" id="deliverDefault" type="checkbox" class="checkbox" value="" <?php if($vv["type"] == 1): ?>checked<?php endif; ?>>设置为默认地址
								</label>
								<input addressid="0" id="deliverBotton_<?php echo ($vv["id"]); ?>" type="button" class="savebtn w120-btn" value="确认修改">
							</div>
						</div>
						<!-- //删除提示框 -->		
					</li><?php endforeach; endif; ?>					
					<li class="add-edits none" id="add-edits_<?php echo ($vv["id"]); ?>">
						<label>
							<input name="addNewAddress" class="addNewAddress" type="radio" value="" >添加新地址
						</label>
						<div class="closeButton" style="display:block">
							<a class="closebtn" style="cursor:pointer;">关闭</a>
						</div>                                
						<div class="infor-editor editBox " id="infor-editor">
							<dl>
								<dt><em class="xh">*</em>收货人：</dt>
								<dd>
									<input name="tname" id="deliverName" type="text" value="" class="text recinput" maxlength="10">
									<span class="wrong-tips none" id="deliverNameTips">请填写收货人</span>
								</dd>
							</dl>
							<dl class="area">
								<dt>
									<em class="xh">*</em>所在地区：
								</dt>
								<dd class="clearfix">
									<select name="province" id="pro">
										<option value=""></option>
									</select>

									<select name="city" id="ci">
										<option value=""></option>
									</select>

									<select name="area" id="ar">
										<option value=""></option>
									</select>	
								</dd>
							</dl>                                        
							<dl class="detailed-address">
								<dt><em class="xh">*</em>详细地址：</dt>
								<dd>
									<input name="address" id="deliverAddr" type="text" value="" class="text addinput" maxlength="30"><span class="wrong-tips none" id="deliverAddressTips">请填写详细地址，5~30字</span>
								</dd>
							</dl>
							<div class="number clearfix">
								<dl>
									<dt><em class="xh">*</em>手机号码：</dt>
									<dd>
										<input name="mobli" id="deliverMobile" type="text" value="" class="text" maxlength="11">
										<em class="tips">或</em>
									</dd>
								</dl>
								<dl class="fixed-line">
									<dt>固定电话：</dt>
									<dd>
										<input name="telp" id="deliverPhone" type="text" value="" class="text" maxlength="17">
										<em class="tips" id="deliverMobilePhoneTips" style="line-height:25px">手机号码和固定电话请至少输入一个</em>
									</dd>

								</dl>
							</div>
							<label class="setup-default">
								<input name="deliverDef" id="deliverDefault" type="checkbox" class="checkbox" value="">设置为默认地址
							</label>
							<input addressid="0" id="deliverButton" type="button" class="savebtn w120-btn" value="确认收货地址">
						</div>
					</li>
				</ul>                  
				<div class="add-address"><label><input name="addAddress" type="radio" id="addradd">添加新地址（最多可添加<span style="color:red">10</span>个地址,您还可以添加<span style="color:red"><?php echo ($geshu); ?></span>个地址）</label></div>
			</td>
		</tr>
	</tbody></table>
</div>
<!-- //收货人信息 -->

 <!-- 购物车商品信息 -->      		
	<div class="order-list order-current">
	<table>
		<tbody><tr>
			<td class="cell-1"><label><input name="merchantId" type="radio" invoice="0" checked="">商品订单</label></td>
			<td class="cell-2">
				<table class="goods">
				   <tbody>
					<tr>
						<th class="infor">商品信息</th>
						<th class="color-suits">颜色套装</th>
						<th class="saletype">销售类型</th>
						<th class="price">单价</th>
						<th class="agio">优惠</th>
						<th class="amount">数量</th>
						<th class="total">总价</th>
					</tr>
					<?php if(is_array($res)): foreach($res as $key=>$v): ?><tr>
						<td class="infor">
							<a href="" target="_blank" class="pic"><img width="60" height="60" src="/zj125/Public/Home/order/img/ChMkJlb6QAyITDmIAAJ6V9u2AqcAAOwSQJ4QpUAAnpv284.jpg" alt="【快递包邮】<?php echo ($v["goods_desc"]); ?>"></a>
							<h3 class="title"><a href="" target="_blank"> 【快递包邮<?php echo ($v["goods_desc"]); ?>】</a></h3>
						</td>																		  <td class="color-suits">
							<div class="color"><?php echo ($v["goods_color"]); ?></div>
							<div class="suits" id="suit-details-6315358" fn="6315358">
								<span><?php echo ($v["goods_tc"]); ?></span>
								<div class="suit-details">
									<i class="ico"></i>
									<p>套装详情：</p>											<p><?php echo ($v["goods_tc_desc"]); ?></p>
								</div>
							</div>
						</td>                                     
						<td class="saletype">-</td>    
						<td class="price">￥<?php echo ($v["goods_price"]); ?></td>
						<td>--</td>
						<td class="amount"><?php echo ($v["goods_num"]); ?></td>
						<td class="total">￥<?php echo ($v["goods_price"]); ?></td>
					</tr><?php endforeach; endif; ?>
					</tbody>
				</table>
				<div class="order-foot clearfix">
					<div class="store-infor">
						<span class="name">店铺：<a href="">志研数码手机专营店</a></span>        
						<a class="tag-security">z保障+</a>
					</div>
					<div class="delivery">
						<div class="payment">
							<select name="payType-192949" onchange="$.changeShipping()" id="payType-192949"><option value="2" selected="">网上支付</option></select>
							<span>支付方式：</span>
						</div>
						<div class="express">
							<select name="shipping-192949" onchange="$.changeShipping()" id="shipping-192949"><option value="88" selected="">顺丰包邮：0元</option></select>
							<span>到 <em id="sendArea-192949">北京&nbsp;海淀区&nbsp;&nbsp;</em>配送方式：</span>
						</div>
					</div>
				</div>
			</td>
		</tr></tbody>
	</table>
</div>

<!-- //购物车商品信息 -->
	
<!-- 订单发票 -->
<div class="container consignee" id="order_invoice_div">
	<table>
		<tbody><tr>
			<td class="cell-1">发票</td>
			<td class="cell-2">
				<div class="invoice clearfix" id="invoice-show-div">
					<input type="hidden" name="isInvoice" id="is_invoice" value="0">
					<span id="invoice_type_name"></span>
					<span id="invoice_name_tips" class="invoice-tips">不需要发票</span>
					<a href="" id="invoice-editor">修改</a>
				</div>
				<div class="infor-editor invoice-editor" id="invoice-editor-div">
					<dl>
						<dt><em class="xh">*</em>发票类型：</dt>
						<dd>
							<label><input name="invoiceType" type="radio" value="1" checked="">普通发票</label>
						</dd>
					</dl>
					<dl>
						<dt><em class="xh">*</em>发票抬头：</dt>
						<dd>
							<input name="invoiceName" type="text" value="姓名/公司名称" class="text text-color" maxlength="30">
							<span class="wrong-tips" id="invoice_error" style="display:none;">发票信息错误</span>
						</dd>
					</dl>
					<div class="btn clearfix">
						<input type="button" id="save_invoice_info" class="savebtn w120-btn" value="保存发票信息">
						<a href="" id="invoice_cancel" class="cancel">取消</a>
					</div>
				</div>
			</td>
		</tr>
	</tbody></table>
</div>
<!-- //订单发票 -->

<!-- 订单备注 -->
<div class="order-note">
	<table>
		<tbody><tr>
			<td class="cell-1">订单备注</td>
			<td class="cell-2"><textarea name="buyer-note-191829" id="orderNote" fn="limit" limit="200" tipsid="haveFonts" style="color:#999999;">您可以填写对商品、配送的要求...</textarea><span><em id="haveFonts">0</em>/200</span></td>
			<td class="cell-3">
				<ul class="total-price">
					<li><span>商品总价：</span><em id="goods-total-price">￥<{}></em></li>
					<li><span>运费：</span><em id="goods-freight-price">￥-</em></li>
					<li><span>订单总计：</span><em class="total" id="total-price">￥<{}></em></li>
				</ul>
			</td>
		</tr>
	</tbody></table>
	</div>
	</form>
	<!-- //订单备注 -->
	<!-- 提交订单 -->
	<div class="submit-order clearfix">
        <a href="<?php echo U('Showcar/showcar');?>" class="submit-return">返回修改购物车</a>
        <input class="submit-btn" name="confirmOrder" type="button" value="提交订单">
		<div class="submit-loading" style="display:none;">提交中...</div>
		<div class="fail-submit" style="display:none;cursor: not-allowed" title="填写错误，不能提交订单">不能提交订单</div>
        	</div>
	<!-- //提交订单 -->
    
	</div>

	<!-- 删除提示框 -->
	<div class="delete-tooltip-box" id="deleteBox" style="display:none;">
		<div class="delete-tooltip">
			<i class="close"></i>
			<p>请问确认删除地址吗？</p>
			<div class="btn clearfix"><a href="" class="ack-btn">确认删除</a><a href="" class="cancel-btn">取消</a></div>
		</div>
	</div>
	<div class="delete-tooltip-box" id="order-submit-box" style="display:none;">
		<div class="delete-tooltip">
			<i class="close" ></i>
			<p>亲，有错误额！</p>
		</div>
	</div>

	<!-- //删除提示框 -->

	<script>

		function refresh(){
		window.location.reload();				 
		}

		//获取省	
		$.get("<?php echo U('addrquery');?>",{fid:1},function(data){
			var html = '<option value="">请选择</option>';
			$(data).each(function(k,v){
				//console.log(v);
				html +='<option value="'+v.id+'">'+v.name+'</option>';				
			});
			$('[name="province"]').html(html);
		},'json');


		//获取市
		$('[name="province"]').change(function(){;
			var fid = $(this).val();
			$.get("<?php echo U('addrquery');?>",{fid:fid},function(data){		
			var html = '<option value="">请选择</option>';
			$(data).each(function(k,v){
				//console.log(v);
				html +='<option value="'+v.id+'">'+v.name+'</option>';
				});
				$('[name="city"]').html(html);
			},'json');
		});

		//获取区县
		$('[name="city"]').change(function(){
			var fid = $(this).val();		
			$.get("<?php echo U('addrquery');?>",{fid:fid},function(data){	
			var html = '<option value="">请选择</option>';
			$(data).each(function(k,v){
				//console.log(v);
				html +='<option value="'+v.id+'">'+v.name+'</option>';
			});
			$('[name="area"]').html(html);
			},'json');
		});


		///////////显示添加地址框/////////////////
		$("input[name=addAddress]").change(function(){
			$("input[name=addNewAddress]").attr("checked","checked");//选中
			$("input[name=addressId]").removeAttr("checked");//不选中
			$('.add-edits').show();
			$('.add-address').hide();
		});

		$(".closebtn").click(function(){
			$('.add-edits').hide();
			$('.add-address').show();
			$("input[name=addressId]").attr("checked","checked");//选中
			$("input:radio[name=addAddress]").prop("checked",false);//不选中
		});

	

		////////////添加收货地址///////////////
		$("#deliverButton").click(function(){
			//添加用户的弹窗
			var uid = $("input[name='uid']").val();
			var person = $('.add-edits [name="tname"]').val();
			var province = $("#pro option:checked").val();
			var city = $("#ci option:checked").val();
			var area = $("#ar option:checked").val();
			var pro = $("#pro option:checked").text();
			var ci= $("#ci option:checked").text();
			var ar = $("#ar option:checked").text();
			var address = pro+ci+ar;
			var xxaddress = $('#deliverAddr').val();
			var moblie = $('.add-edits [name="mobli"]').val();
			var tel = $('.add-edits [name="telp"]').val();
			if($('input[name="deliverDef"]').is(':checked')){
				var type = 1;
			}else{
				var type = 0;
			}
			console.log(type);	  
			$.post('<?php echo U("addressadd");?>',{uid:uid,person:person,province:province,city:city,area:area,address:address,pro:pro,ci:ci,ar:ar,xxaddress:xxaddress,moblie:moblie,tel:tel,type:type},function(da){				
				$('.msg').text(da.msg);
				$('.msg').slideDown('fast');
				setTimeout(function(){$('.msg').slideUp('fast');},1600);						
			},'json');
			$('.add-edits').hide();
			//refresh();
			
		});

		//////////////删除地址/////////////////
		$(".addrdele").click(function(){
			var id = $(this).attr("data-id");
			console.log(id);
			$("#deleteBox").show();
		});

		$(".cancel-btn").click(function(){
			$("#deleteBox").hide();
		});

		///////////确认删除////////////current//
		$(".ack-btn").click(function(){
			var id = $(this).parent().parent().parent().parent().attr("id");
			console.log(id);
			//exit;
			$.get('<?php echo U("addressDel");?>',{id:id},function(data){
			if(data.status){				
				$("#"+id).remove();
				$('.msg').text(data.msg);
				$('.msg').slideDown('fast');
				setTimeout(function(){$('.msg').slideUp('fast');},1600);
				}
			},'json');	
			 //refresh();
			$("#deleteBox").hide();
		});

		////////////修改地址/////////////////
		$(".addredit").click(function(){
			$(".closeButton").show();
			//$('[name="province"]').change();
			var id = $(this).attr('data-id');
			$("#closeButton_"+id).show();
			 $.get('<?php echo U("addrchaxun");?>',{id:id},function(data){
				 $("input[name='uid']").val(data.uid);
				 $('.editBox [name="truename"]').val(data.person);
				 $("#province option:checked").val(data.province);
				 $("#city option:checked").val(data.city);
				 $("#area option:checked").val(data.area);
				 $("#province option:checked").text(data.province);
				 $("#city option:checked").text(data.city);
				 $("#area option:checked").text(data.area);
				 $('.editBox [name="addres"]').val(data.xxaddress);
				 $('.editBox [name="moblie"]').val(data.moblie);
				 $('.editBox [name="tel"]').val(data.tel);
				 //$(".editBox_"+id+" [name='deliverDefault']").val(data.type);
				 console.log(data.type);
				 
			},'json');
				$("#infor-editor_"+id).show();
				$("#operate_"+id).hide();

				$("#deliverBotton_"+id).click(function(){
					var person = $(".editBox_"+id+" [name='truename']").val();
					var province = $("#province_"+id+" option:checked").val();
					var city = $("#city_"+id+" option:checked").val();
					var area = $("#area_"+id+" option:checked").val();
					var pro = $("#province_"+id+" option:checked").text();
					var ci = $("#city_"+id+" option:checked").text();
					var ar = $("#area_"+id+" option:checked").text();
					var address = pro+ci+ar;
					//console.log(address);
					var xxaddress =  $(".editBox_"+id+" [name='addres']").val();
					//console.log(xxaddress);
					var moblie = $(".editBox_"+id+" [name='moblie']").val();
					//console.log(moblie);
					var tel =  $(".editBox_"+id+" [name='tel']").val();
					//console.log(tel);
					if($(".editBox_"+id+" [name='deliverDefault']").is(':checked')){
						var type =1;
					}else{
						var type = 0;
					}
					console.log(type);	  
					$.post('<?php echo U("addredit");?>',{id:id,person:person,province:province,city:city,area:area,address:address,xxaddress:xxaddress,moblie:moblie,tel:tel,type:type},function(data){
						console.log(data);				
						$('.msg').text(data.msg);
						$('.msg').slideDown('fast');
						setTimeout(function(){$('.msg').slideUp('fast');},1600);						
					},'json');
					$("#infor-editor_"+id).hide();
					//refresh();
					
				});
			});

		/*
		请选择：
		<select id="sel">
			<option value="1">选项1</option>
			<option value="2">选项2</option>
			<option value="3">选项3</option>
			<option value="4">选项4</option>
		</select>
		<input type="button" value="点击查看被选项目">

		$(function(){
			$("input").click(function() {
				a = $("#sel").val();
				b = $("#sel option:checked").text();
				alert("被选项目的值："+a+"，被选项目的显示值："+b+"。");
			});
		})

		*/
	</script>
</body></html>